﻿/// <reference path="" />
function XWFToolboxView() {
    XWFView.apply(this, []);

    this.key = "Toolbox";

    //#override
    //安装渲染视图相关DOM元素
    this.onInstall = function (designer, callback) {
        this._domEl.style.backgroundColor = "gray";
        //this._domEl.setAttribute("ng-include","'../Templates/XWFToolbox.html'");
        this.includeHtml(config.getTemplateByKey(this.key),this.loadAllActives);

        callback();
    }

    var that = this;
    this.loadAllActives = function () {
        $.ajax({
            type: 'get',
            url: "/api/designerapi.ashx?sys:cmd=getactivitylist",
            data: null,
            dataType: "text",
            success: function (data) {
                data = eval("(" + data + ")");
                var html = baidu.template("wftoolbox", data);
                $(that._domEl).append($(html));
                that.renEvent();
            }
        });
    }

    this.renEvent = function () {
        this._domEl.addEventListener("click", function (e) {
            var o = e.target;
            if (o.tagName.toLowerCase() == "img" && o.getAttribute("tag") == "expand") {
                var expandTag = o.getAttribute("expand");
                if (expandTag == "true") {
                    $(o).parent().parent().next().css("display", "none");
                    o.setAttribute("expand", "false");
                    o.setAttribute("src", "./Images/expand.png");
                }
                else {
                    $(o).parent().parent().next().css("display", "block");
                    o.setAttribute("expand", "true");
                    o.setAttribute("src", "./Images/collapse.png");
                }
            }
            if (o.getAttribute("types") == "Activity") {
                console.log(o.getAttribute("wfClass"))
                designer.drawAction(o.getAttribute("wfClass"));
            }
        })
    }
}